﻿using System;
using System.Data;
using Framework;
namespace Enterprise.Admin.Handle
{
    /// <summary>
    /// 修改密码
    /// </summary>
    public partial class ModifyPassword : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var id = Fq("CoAdminId").SafeToInt();
            var oldpassword = Fq("oldpassword");
            var newpassword = Fq("newpassword");
            if (oldpassword.IsNullOrEmpty())
                Json(new { state = false, message = "原密码不能为空！" });
            if (newpassword.IsNullOrEmpty())
                Json(new { state = false, message = "新密码不能为空！" });
            var adminService = new AdminService();
            var count = adminService.ModifyPassword(id, oldpassword, newpassword);
            if (count > 0)
            {
                Json(new { state = false, message = "修改成功！" });
            }
            Session["code"] = null;
            Json(new { state = false, message = "原密码错误！" });


        }
    }
}